#include "ZigbeeGWDeviceJoinCmd.h"

ZigbeeGWDeviceJoinCmd::ZigbeeGWDeviceJoinCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::ZigbeeGWProtocol;
    this->m_functionCode = FunctionCode;
}

Package ZigbeeGWDeviceJoinCmd::toPackage()
{
    Package package;
    package.setFunction(FunctionCode);
    return package;
}

void ZigbeeGWDeviceJoinCmd::unPackage(Package package)
{
    qDebug()<<"unpackage zigbee newcmd";
    qDebug()<<package.body().toHex().data();
    QByteArray body = package.body();
    m_nwk=body.mid(3,1);
    m_nwk.append(body.mid(2,1));
    for(int i=0;i<8;i++)
    {
        m_mac.append(body.mid(11-i,1));
    }
    qDebug()<<"m_nwk="<<m_nwk;
    qDebug()<<"m_mac="<<m_mac;
}
QByteArray ZigbeeGWDeviceJoinCmd::Mac()
{
    return m_mac;
}
QByteArray ZigbeeGWDeviceJoinCmd::Nwk()
{
    return m_nwk;
}
